package com.mbigger.admin.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mbigger.admin.dto.DeptLevelDto;
import com.mbigger.admin.param.DeptParam;
import com.mbigger.admin.service.DeptService;
import com.mbigger.admin.service.TreeService;

@RestController
@RequestMapping("/sys/dept")
public class DeptController {

	@Autowired
	private DeptService deptService;
	@Autowired
	private TreeService treeService;

	@GetMapping("/tree")
	public List<DeptLevelDto> tree() {
		return treeService.deptTree();
	}

	@PostMapping("/save")
	public Integer sava(DeptParam param) {
		return deptService.save(param);
	}

	@DeleteMapping("/delete")
	public void delete(int id) {
		deptService.delete(id);
	}

	@PostMapping("/update")
	public void updateDept(DeptParam param) {
		deptService.update(param);
	}

}
